package com.wms.common.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.wms.common.model.SessionUserInfo;

/**
 * A base action class for cloud web application. All the c relative class
 * must inherit this class. Also, this class could includes some abstracted 
 * or common methods for sub class.
 *  
 */
public class CIBaseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware {
	
	/** The default serial version id. */
	private static final long serialVersionUID = 1L;
	
	protected HttpServletRequest request;

	protected HttpServletResponse response;

	protected HttpSession session;

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
		this.session = request.getSession();
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	
	protected SessionUserInfo getSessionUserInfo(){
		return (SessionUserInfo)session.getAttribute("SessionUserInfo");
	}
	
	protected void setSessionUserInfo(SessionUserInfo userInfo){
		session.setAttribute("SessionUserInfo", userInfo);
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}
	
}
